<?php

/**

 * cms首页

 *

 *

 * * @网店运维 (c) 2015-2018  Inc. (http://www.shopwwi.com)
 * @license    http://www.shopwwi.c om
 * @link       交流群号：111731672
 * @since      网店运维提供技术支持 授权请购买shopnc授权

 */



//use Shopnc\Tpl;



defined('InShopNC') or exit('Access Invalid!');

class indexControl extends mobileHomeControl{



    public function __construct() {

        parent::__construct();

    }


    /**
     * 首页
     */

    public function indexOp() {

        $model_mb_special = Model('mb_special');

        $data = $model_mb_special->getMbSpecialIndex();

        if(!empty($_SESSION['member_name'])) {
            Tpl::output('member_name',empty($_SESSION['member_nickname']) ? $_SESSION['member_name']:$_SESSION['member_nickname']);
        }
        $model_link = Model('mb_sliders');
        $link_list = $model_link->getLinkList(array());
        Tpl::output('slider_list',$link_list);

        $model_article = Model("article");
        $article = $model_article->getArticleList(array('ac_id'=>1,'article_position'=>1,'article_show'=>1, 'limit'=>1));
        Tpl::output('article',$article);

        $model_xianshi_goods = Model('p_xianshi_goods');
        $xianshi_item = $model_xianshi_goods->getXianshiGoodsCommendList(1,11,'rand()');
        Tpl::output('xianshi_item', $xianshi_item);

        $model_adv = Model("adv");
        $top_adv = $model_adv->getList(array('ap_id'=>101,'position'=>1),'','','adv_id asc');
        Tpl::output('top_adv',$top_adv);

        $index_banner = $model_adv->getList(array('ap_id'=>101,'position'=>2),'','','adv_id asc');
        Tpl::output('index_banner',$index_banner);

        $index_brand = $model_adv->getList(array('ap_id'=>103),'','','adv_id asc');
        Tpl::output('index_brand',$index_brand);

        $index_product_gold = $model_adv->getList(array('ap_id'=>105,'position'=>1),'','','adv_id asc');
        Tpl::output('product_gold',$index_product_gold);

        $index_product_silver = $model_adv->getList(array('ap_id'=>105,'position'=>2),'','','adv_id asc');
        Tpl::output('product_silver',$index_product_silver);

        $index_product_platinum = $model_adv->getList(array('ap_id'=>105,'position'=>3),'','','adv_id asc');
        Tpl::output('product_platinum',$index_product_platinum);

        $index_product_jewelry = $model_adv->getList(array('ap_id'=>105,'position'=>4),'','','adv_id asc');
        Tpl::output('product_jewelry',$index_product_jewelry);

        //预售、预定商品
        $model_presale = Model("presale_promotion");
        $condition = array('presale_promotion'=>array('status'=>1,'place'=>1,'start_time'=>array('lt',time()),'end_time'=>array('gt',time())));
        $goods_list = $model_presale->getPresaleGoodsList($condition,  '*', 8, 'rand()');
        Tpl::output('goods_list', $goods_list);

        Tpl::showpage('index');
       // $this->_output_special($data, $_GET['type']);

    }



    /**

     * 专题

     */

    public function specialOp() {

        $model_mb_special = Model('mb_special');

        $data = $model_mb_special->getMbSpecialItemUsableListByID($_GET['special_id']);

        $this->_output_special($data, $_GET['type'], $_GET['special_id']);

    }



    /**

     * 输出专题

     */

    private function _output_special($data, $type = 'json', $special_id = 0) {

        $model_special = Model('mb_special');

     //   if($_GET['type'] == 'html') {

           // $html_path = $model_special->getMbSpecialHtmlPath($special_id);

          //  if(!is_file($html_path)) {

          //      ob_start();

                Tpl::output('list', $data);

                Tpl::showpage('mb_special');

            //    file_put_contents($html_path, ob_get_clean());

          //  }

          //  header('Location: ' . $model_special->getMbSpecialHtmlUrl($special_id));

          //  die;

   //     } else {

    //        output_data($data);

    //    }

    }

 /**
     * 输出搜索条件
     */

    private function search_advop($data) {

    }



    /**

     * android客户端版本号

     */

    public function apk_versionOp() {

        $version = C('mobile_apk_version');

        $url = C('mobile_apk');

        if(empty($version)) {

           $version = '';

        }

        if(empty($url)) {

            $url = '';

        }



        output_data(array('version' => $version, 'url' => $url));

    }

    /*
     * 文章列表
     *
     * */
    public function articleOp(){
        /**
         * 根据文章编号获取文章信息
         */
        $article_model  = Model('article');
        $article    = $article_model->getOneArticle(intval($_GET['article_id']));
        if(empty($article) || !is_array($article) || $article['article_show']=='0'){

        }
        Tpl::output('article',$article);
        Tpl::showpage('article');
    }
}

